package me.ywy.simplelauncher.base;

import me.ywy.ltnetgame.test.apkinfo.R;
import me.ywy.simplelauncher.home.HomePageActivity;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;

public class AppInfo {
    String packageName;
    String appName;
    View view;
    String info;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    byte appType;

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getAppName() {
        return appName;
    }

    public View getView() {
        return view;
    }

    public void setView(View view) {
        this.view = view;
    }

    public byte getAppType() {
        return appType;
    }

    public void setAppType(byte appThird) {
        this.appType = appThird;
    }

    public void initView(byte type, CharSequence label, String packname, String info, Drawable icon) {
        appType = type;
        packageName = packname;
        this.info = info;
        appName = label.toString();
        view = HomePageActivity.getInstance().getLayoutInflater().inflate(R.layout.app_list_item, null);
        ImageView appIcon = (ImageView) view.findViewById(R.id.item_app_icon);
        appIcon.setImageDrawable(icon);
        TextView appLabel = (TextView) view.findViewById(R.id.item_app_label);
        appLabel.setText(label);
        TextView appName = (TextView) view.findViewById(R.id.item_app_name);
        appName.setText(packname);
        TextView appInfo = (TextView) view.findViewById(R.id.item_app_info);
        appInfo.setText(info);
        setColor(Config.getFontColor());
        setSize(Config.getIconSize());
    }

    public void setColor(int color) {
        ((TextView) view.findViewById(R.id.item_app_label)).setTextColor(Config.getFontColor());
        ((TextView) view.findViewById(R.id.item_app_name)).setTextColor(Config.getFontColor());
        ((TextView) view.findViewById(R.id.item_app_info)).setTextColor(Config.getFontColor());
    }

    public void setSize(int size) {
        ImageView img = (ImageView) view.findViewById(R.id.item_app_icon);
        LayoutParams para;
        para = img.getLayoutParams();
        para.height = size;
        para.width = size;
        img.setLayoutParams(para);
    }
}
